home *** CD-ROM | disk | FTP | other *** search
/ Computer Shopper 235 / Issue 235 - September 2007 - DPCS0907DVD.ISO / Extras / NetObjects Fusion / NOF10.exe / data1.cab / FSI / lib / nof / net / HttpRequest.js < prev    next >
Encoding:
Text File  |  2007-04-11  |  3.2 KB  |  124 lines

  1. /****i* SOURCE_FILE/INFO
  2.   *
  3.   * NAME
  4.   *  HttpRequest.js
  5.   *
  6.   * USAGE
  7.   *  Part of Netobjects JavaScript Library.
  8.   *
  9.   * COPYRIGHT
  10.   *  Copyright ⌐ 2000-2005 Website Pros, Inc.
  11.   *  All Rights Reserved.
  12.   *
  13.   *  This is an unpublished work protected by Website Pros, Inc.
  14.   *  as a trade secret, and is not to be used or disclosed except as
  15.   *  expressly provided in a written license agreement executed by
  16.   *  you and Website Pros, Inc.
  17.   *
  18.   *      <copyright@websitepros.com>
  19.   *
  20.   * NOTES
  21.   *  JavaScript code.
  22.   *
  23.   *****/
  24. if (!IS_isModuleInitialized("IS.NOF.NET.HttpRequest"))
  25. {
  26.   
  27.   /****h* NOF_JavaScript_Library/NOF.NET.HttpRequest
  28.     *
  29.     * NAME
  30.     *  NOF.NET.HttpRequest
  31.     *
  32.     * DESCRIPTION
  33.     *    
  34.     *
  35.     ****/
  36.   
  37.   /**
  38.   * constructor 
  39.   * @param url - URL 
  40.   **/
  41.   function NET_HttpRequest( /*String*/ url ) {
  42.     this.__proto__ = NET_HttpRequest.prototype;
  43.     
  44.     this.URL = url; 
  45.     this.method = "GET";
  46.     
  47.     this.headers = new Array();
  48.     this.includeHeaderResult = false;
  49.     this.includeBodyResult = true;
  50.     this.postData = "";
  51.   }
  52.   {
  53.     var member = NET_HttpRequest.prototype;    
  54.     member.CLASS_NAME            = "NET.HttpRequest";
  55.     
  56.     var method = NET_HttpRequest.prototype;                            
  57.     
  58.     /**
  59.     * Set a header value.
  60.     * 
  61.     * @param headName
  62.     * @param headValue
  63.     **/
  64.     method.addHeader = function (/*String*/ headName, /*String*/ headValue) { this.headers[headName] = headValue; }
  65.     
  66.     /**
  67.     * Set a header value.
  68.     * 
  69.     * @param headName
  70.     * @param headValue
  71.     **/        
  72.     method.setHeader = method.addHeader;
  73.     
  74.     /**
  75.     * Get header value
  76.     * 
  77.     * @return 
  78.     **/        
  79.     method.getHeader = function (/*String*/ headName) { return this.headers[headName]; }
  80.     method.getHeaders = function () { return this.headers; }
  81.     
  82.     /**
  83.     * Set method type. Only POST and GET values are allowed.
  84.     * 
  85.     * @param method can be POST or GET
  86.     **/
  87.     method.setMethod = function (method) { this.method = method; }
  88.     
  89.     /**
  90.     * Get method type
  91.     * 
  92.     * @return POST or GET
  93.     **/        
  94.     method.getMethod = function () { return this.method; }
  95.     
  96.     /**
  97.     * Set additional data to be posted.
  98.     * 
  99.     * @return 
  100.     **/        
  101.     method.setData = function (/*String*/ postData) { 
  102.       this.postData = postData; 
  103.     }
  104.     method.getData = function () { return this.postData; }
  105.     
  106.     /**
  107.     * Specify if the response should include headers. Default value is false.
  108.     * 
  109.     * @param includeHeaderResult boolean
  110.     **/        
  111.     method.setIncludeHeaderResult = function (/*boolean*/ includeHeaderResult) { this.includeHeaderResult = includeHeaderResult; }
  112.     method.getIncludeHeaderResult = function () { return this.includeHeaderResult; }
  113.  
  114.     /**
  115.     * Specify if the response should include content. Default value is true.
  116.     * 
  117.     * @param includeBodyResult boolean
  118.     **/        
  119.     method.setIncludeBodyResult = function (/*boolean*/ includeBodyResult) { this.includeBodyResult = includeBodyResult; }
  120.     method.getIncludeBodyResult = function () { return this.includeBodyResult; }
  121.   }
  122.   
  123.   NET.__proto__.HttpRequest = NET_HttpRequest;
  124. }